<template>
  <div class="full">
    <div class="g-reg-wrap">
      <div class="m-reg-cet">
        <div class="m-reg-header">
          <p class="back">
            <router-link to="/">首页</router-link>
          </p>
          <p class="logo"><img src="../images/logo.png" width="147" height="76"/></p>
        </div>


        <!-- S 注册账号-->
        <div class="m-regbox">
          <div class="hd">
            <p class="btn"><a href="#">直接登录</a></p>
          </div>
          <div class="bd">
            <h2 class="reg-tit">注册账号</h2>
            <div class="m-formlist">
              <!--<p class="error">密码输入重复错误！</p>-->
              <ul class="clearfix">
                <li>
                  <input v-model="mobile" class="int" type="text" name="" value="" placeholder="请输入手机号码"/>
                </li>

                <li>
                  <input v-model="code" class="int" type="text" name="" value="" placeholder="请输入短信验证码"/>
                  <a @click="getVerification" class="txt">获取验证码</a>
                </li>
                <li>
                  <input v-model="password" class="int" type="text" name="" value="" placeholder="请输入密码"/>
                  <!--<a href="#" class="txt">请输入密码</a>-->
                </li>
                <li>
                  <input v-model="invitationCode" class="int" type="text" name="" value="" placeholder="请填写邀请码（非必填）"/>
                </li>
              </ul>
              <p class="btn">
                <a @click="register">确认</a>
              </p>
            </div>
          </div>
        </div>

      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "regster",
    data() {
      return {
        mobile: '',
        password: '',
        code: '',
        invitationCode: '',
      }
    }, methods: {
      getVerification() {
        if (this.mobile.length != 11) {
          this.$message.error('手机号码长度不对');
          return;
        }
        let params = {
          "mobile": this.mobile,
          "type": 'reg'
        }
        this.$post('/user/sendMessage', params).then(response => {
          this.$check(response)
        })
      },
      register() {
        let params = {
          "code": this.code,
          "mobile": this.mobile,
          "password": this.password,
          "invitationCode": this.invitationCode
        }
        this.$post('/user/register', params).then(response => {
          this.$check(response)
          window.location.href = '/#/login/'
        })
      }


    }
  }
</script>

<style scoped>
  .full {
    background: #64abe1;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
  }

</style>
